#!/bin/sh
###############################################################################
## File: make_tar
##
## Builds the TCW release package.
## First makes a directory with the name of the release. 
## Then copies in the relevant files, tars it, and deletes it. 
## It also builds the project, in case stcw.jar and mtcw.jar are not present.
## 11/27 add 'make sign'
## run on ECO
###############################################################################

P=TCW_1_3

if [ -d $P ]
then
echo "$P exists; delete? y/n"
read answer
if [ "$answer" != "y" ]
then 
exit
fi 
fi

rm -Rf $P
mkdir $P
cd java
make
make sign -f Makefile.digicert
cd ..

if [ -f $P.tar.gz ]
then
rm $P.tar.gz
fi
if [ -f $P.tar ]
then
rm $P.tar
fi

# Note, run only on clean checkout else will copy log files, etc.
mkdir $P/libraries
cp -R libraries/demoOl_DE $P/libraries
cp -R libraries/demoZo_ASM $P/libraries
cp -R libraries/demoCl_NR $P/libraries

mkdir $P/projects
cp -R projects/demoOl_DE $P/projects
cp -R projects/demoZo_ASM $P/projects
cp -R projects/demoCl_NR $P/projects


mkdir $P/projects/DBfasta
cp -R projects/DBfasta/demo4 $P/projects/DBfasta

cp -R scripts $P
cp -R external $P
cp -R external_osx $P
cp  runSingleTCW $P
cp  runMultiTCW $P
cp  viewSingleTCW $P
cp  viewMultiTCW $P
cp  runDE $P
cp  execLoadLib.pl $P
cp  execAssm.pl $P
cp  execAnno $P
cp  HOSTS.cfg.release $P/HOSTS.cfg
cp  LICENSE $P
cp  README $P
mkdir $P/java
cp -R java/jars $P/java/jars

tar cf  $P.tar $P --exclude=".svn" --exclude="*.removed"
rm -Rf $P

rm -Rf java/classes/*
mv java $P.src
tar cf $P.src.tar $P.src/Makefile $P.src/src $P.src/classes $P.src/jars --exclude=".svn" --exclude="*.removed"
mv $P.src java


